package com.fesine.spring.framework;

/**
 * @description: 类描述
 * @author: Fesine
 * @createTime:2016/12/4 19:36
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2016/12/4 19:36
 */
public class WorkerThread extends Thread {
    private int tickets = 10;
    private String name;

    public WorkerThread(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            if (tickets > 0) {
                System.out.println(this.name+" 卖票---->"+(this.tickets--));
            }
        }
    }

    public static void main(String[] args) {
        //其实是new了三个对象，三个线程分别在执行
        WorkerThread t1 = new WorkerThread("1号窗口");
        WorkerThread t2 = new WorkerThread("2号窗口");
        WorkerThread t3 = new WorkerThread("3号窗口");
        t1.start();
        t2.start();
        t3.start();

    }
}
